package com.xjy.web.controller.controller;

import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.enums.BusinessType;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.system.domain.bo.FundLedgerDetailQueryBo;
import com.xjy.system.domain.vo.FundLedgerDetailVo;
import com.xjy.system.service.IFundLedgerDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 资金流水明细报表Controller
 *
 * @author mlb
 * @date 2022-03-26
 */
@Api(value = "资金流水明细报表控制器", tags = {"资金流水明细报表管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/fund_ledger_detail")
public class FundLedgerDetailController extends BaseController {

    private final IFundLedgerDetailService iFundLedgerDetailService;

    /**
     * 查询资金流水明细报表列表
     */
    @ApiOperation("查询资金流水明细报表列表")
    @PreAuthorize("@ss.hasPermi('system:fund_ledger_detail:list')")
    @GetMapping("/list")
    public TableDataInfo<FundLedgerDetailVo> list(@Validated FundLedgerDetailQueryBo bo) {
        return iFundLedgerDetailService.queryPageList(bo);
    }

    /**
     * 导出资金流水明细报表列表
     */
    @ApiOperation("导出资金流水明细报表列表")
    @PreAuthorize("@ss.hasPermi('system:fund_ledger_detail:export')")
    @Log(title = "资金流水明细报表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<FundLedgerDetailVo> export(@Validated FundLedgerDetailQueryBo bo) {
        List<FundLedgerDetailVo> list = iFundLedgerDetailService.queryList(bo);
        ExcelUtil<FundLedgerDetailVo> util = new ExcelUtil<FundLedgerDetailVo>(FundLedgerDetailVo.class);
        return util.exportExcel(list, "资金流水明细报表");
    }

    /**
     * 获取资金流水明细报表详细信息
     */
    @ApiOperation("获取资金流水明细报表详细信息")
    @PreAuthorize("@ss.hasPermi('system:fund_ledger_detail:query')")
    @GetMapping("/{transactionDate}")
    public AjaxResult<FundLedgerDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("transactionDate") Date transactionDate) {
        return AjaxResult.success(iFundLedgerDetailService.queryById(transactionDate));
    }
}
